# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=pmacct
pkgver=v1.7.6.r1680.ga92abef
pkgrel=1
epoch=1
pkgdesc='Small set of multi-purpose passive network monitoring tools [NetFlow IPFIX sFlow libpcap BGP BMP IGP Streaming Telemetry].'
groups=('blackarch' 'blackarch-networking' 'blackarch-sniffer'
        'blackarch-defensive')
arch=('x86_64' 'aarch64')
url='https://github.com/pmacct/pmacct'
license=('GPL2')
depends=('libpcap' 'zeromq' 'rabbitmq' 'mariadb' 'geoip')
makedepends=('git' 'autoconf')
source=("git+https://github.com/pmacct/$pkgname.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

	( set -o pipefail
    git describe --long --tags --abbrev=7 2>/dev/null |
      sed 's/\([^-]*-g\)/r\1/;s/-/./g' ||
    printf "%s.%s" "$(git rev-list --count HEAD)" \
      "$(git rev-parse --short=7 HEAD)"
  )
}

build() {
  cd $pkgname

  ./autogen.sh

  autoreconf

  ./configure --prefix=/usr --sbindir=/usr/bin

  make
}

package() {
  cd $pkgname

  make DESTDIR="$pkgdir" install

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" *.md AUTHORS ChangeLog \
    FAQS INSTALL QUICKSTART UPGRADE
  cp -a docs/* "$pkgdir/usr/share/doc/$pkgname/"
  install -Dm 644 COPYING "$pkgdir/usr/share/licenses/$pkgname/COPYING"
}

